// pages/help/help.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 0,
    trues: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(app.globalData.globaldataIndex)
    console.log("app.globalData.globaldataIndex////////////////////////////////////////")
    var _that = this
    _that.setData({
      newHelp: app.globalData.globaldataIndex
    })

    
    _that.help();
    _that.feedback();

  },

  /** 
   * 点击tab切换 
   */
  swichNav: function(e) {
    var that = this;
    console.log("ok");
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  // 截获竖向滑动
  catchTouchMove: function (res) {
    return false
  },

  /** 
   * 滑动切换tab 
   */
  bindChange: function(e) {
    var a = e.detail
    var b = e.detail.current
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
    console.log(a)
    console.log(b)
  },


  // 帮助
  help: function() {
    var that = this;
    var url = app.util.url('entry/wxapp/hellp')
    app.util.request({
      url: url,
      data: {
        m: 'md_daojia',
      },
      success: function(res) {
        var list = res.data.data
        that.setData({
          helpList: list
        })
        console.log("帮助=========>", res);

      }
    })
  },
  // 反馈
  feedback: function() {
    var that = this;
    var url = app.util.url('entry/wxapp/feedsaid')
    app.util.request({
      url: url,
      data: {
        m: 'md_daojia',
      },
      success: function(res) {
        var list = res.data.data
        that.setData({
          feedbackList: list
        })
        console.log("反馈说明=========>", res);

      }
    })
  },

  // 获取反馈文本内容
  btnText: function(t) {
    var btnText = t.detail.value
    this.setData({
      btnTexts: btnText
    })
  },


  // 反馈保存
  formSubmit: function() {
    var that = this;
    var url = app.util.url('entry/wxapp/feedback')
    app.util.request({
      url: url,
      data: {
        m: 'md_daojia',
        uid: wx.getStorageSync('userInfo'),
        content: that.data.btnTexts
      },
      success: function(res) {
        var list = res.data.data
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
        console.log("反馈保存=========>", res);

      }
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})